package com.jikangjun.disk.file.entity;

import java.util.Date;
import java.util.List;


public class FileCopyStatus {
    
    /**
     * 操作ID
     */
    private String operationId;
    
    /**
     * 操作状态
     */
    private String status;
    
    /**
     * 操作进度（百分比）
     */
    private int progress;
    
    /**
     * 开始时间
     */
    private Date startTime;
    
    /**
     * 预计完成时间
     */
    private Date estimatedEndTime;
    
    /**
     * 已处理文件数
     */
    private int processedFiles;
    
    /**
     * 总文件数
     */
    private int totalFiles;
    
    /**
     * 成功文件数
     */
    private int successFiles;
    
    /**
     * 失败文件数
     */
    private int failedFiles;
    
    /**
     * 当前处理的文件名
     */
    private String currentFileName;
    
    /**
     * 当前文件大小
     */
    private long currentFileSize;
    
    /**
     * 已传输字节数
     */
    private long transferredBytes;
    
    /**
     * 总字节数
     */
    private long totalBytes;
    
    /**
     * 传输速度（字节/秒）
     */
    private long transferSpeed;
    
    /**
     * 剩余时间（秒）
     */
    private long remainingTime;
    
    /**
     * 错误信息列表
     */
    private List<String> errorMessages;
    
    /**
     * 成功文件列表
     */
    private List<String> successFileList;
    
    /**
     * 失败文件列表
     */
    private List<String> failedFileList;
    
    /**
     * 操作类型
     */
    private String operationType;
    
    /**
     * 目标路径
     */
    private String targetPath;
    
    /**
     * 操作用户ID
     */
    private String userId;

    // 默认构造函数
    public FileCopyStatus() {
        this.startTime = new Date();
        this.progress = 0;
        this.processedFiles = 0;
        this.successFiles = 0;
        this.failedFiles = 0;
        this.transferredBytes = 0;
        this.transferSpeed = 0;
        this.remainingTime = 0;
    }

    // 带参数的构造函数
    public FileCopyStatus(String operationId, String status) {
        this.operationId = operationId;
        this.status = status;
        this.startTime = new Date();
        this.progress = 0;
        this.processedFiles = 0;
        this.successFiles = 0;
        this.failedFiles = 0;
        this.transferredBytes = 0;
        this.transferSpeed = 0;
        this.remainingTime = 0;
    }

    // Getters and Setters
    public String getOperationId() {
        return operationId;
    }

    public void setOperationId(String operationId) {
        this.operationId = operationId;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public int getProgress() {
        return progress;
    }

    public void setProgress(int progress) {
        this.progress = progress;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEstimatedEndTime() {
        return estimatedEndTime;
    }

    public void setEstimatedEndTime(Date estimatedEndTime) {
        this.estimatedEndTime = estimatedEndTime;
    }

    public int getProcessedFiles() {
        return processedFiles;
    }

    public void setProcessedFiles(int processedFiles) {
        this.processedFiles = processedFiles;
    }

    public int getTotalFiles() {
        return totalFiles;
    }

    public void setTotalFiles(int totalFiles) {
        this.totalFiles = totalFiles;
    }

    public int getSuccessFiles() {
        return successFiles;
    }

    public void setSuccessFiles(int successFiles) {
        this.successFiles = successFiles;
    }

    public int getFailedFiles() {
        return failedFiles;
    }

    public void setFailedFiles(int failedFiles) {
        this.failedFiles = failedFiles;
    }

    public String getCurrentFileName() {
        return currentFileName;
    }

    public void setCurrentFileName(String currentFileName) {
        this.currentFileName = currentFileName;
    }

    public long getCurrentFileSize() {
        return currentFileSize;
    }

    public void setCurrentFileSize(long currentFileSize) {
        this.currentFileSize = currentFileSize;
    }

    public long getTransferredBytes() {
        return transferredBytes;
    }

    public void setTransferredBytes(long transferredBytes) {
        this.transferredBytes = transferredBytes;
    }

    public long getTotalBytes() {
        return totalBytes;
    }

    public void setTotalBytes(long totalBytes) {
        this.totalBytes = totalBytes;
    }

    public long getTransferSpeed() {
        return transferSpeed;
    }

    public void setTransferSpeed(long transferSpeed) {
        this.transferSpeed = transferSpeed;
    }

    public long getRemainingTime() {
        return remainingTime;
    }

    public void setRemainingTime(long remainingTime) {
        this.remainingTime = remainingTime;
    }

    public List<String> getErrorMessages() {
        return errorMessages;
    }

    public void setErrorMessages(List<String> errorMessages) {
        this.errorMessages = errorMessages;
    }

    public List<String> getSuccessFileList() {
        return successFileList;
    }

    public void setSuccessFileList(List<String> successFileList) {
        this.successFileList = successFileList;
    }

    public List<String> getFailedFileList() {
        return failedFileList;
    }

    public void setFailedFileList(List<String> failedFileList) {
        this.failedFileList = failedFileList;
    }

    public String getOperationType() {
        return operationType;
    }

    public void setOperationType(String operationType) {
        this.operationType = operationType;
    }

    public String getTargetPath() {
        return targetPath;
    }

    public void setTargetPath(String targetPath) {
        this.targetPath = targetPath;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    /**
     * 计算传输进度百分比
     */
    public void calculateProgress() {
        if (this.totalBytes > 0) {
            this.progress = (int) ((this.transferredBytes * 100) / this.totalBytes);
        }
    }

    /**
     * 计算剩余时间
     */
    public void calculateRemainingTime() {
        if (this.transferSpeed > 0 && this.totalBytes > this.transferredBytes) {
            long remainingBytes = this.totalBytes - this.transferredBytes;
            this.remainingTime = remainingBytes / this.transferSpeed;
        }
    }

    /**
     * 更新传输速度
     */
    public void updateTransferSpeed(long bytesPerSecond) {
        this.transferSpeed = bytesPerSecond;
        this.calculateRemainingTime();
    }

    /**
     * 增加已传输字节数
     */
    public void addTransferredBytes(long bytes) {
        this.transferredBytes += bytes;
        this.calculateProgress();
    }

    @Override
    public String toString() {
        return "FileCopyStatus{" +
                "operationId='" + operationId + '\'' +
                ", status='" + status + '\'' +
                ", progress=" + progress +
                ", startTime=" + startTime +
                ", estimatedEndTime=" + estimatedEndTime +
                ", processedFiles=" + processedFiles +
                ", totalFiles=" + totalFiles +
                ", successFiles=" + successFiles +
                ", failedFiles=" + failedFiles +
                ", currentFileName='" + currentFileName + '\'' +
                ", currentFileSize=" + currentFileSize +
                ", transferredBytes=" + transferredBytes +
                ", totalBytes=" + totalBytes +
                ", transferSpeed=" + transferSpeed +
                ", remainingTime=" + remainingTime +
                ", operationType='" + operationType + '\'' +
                ", targetPath='" + targetPath + '\'' +
                ", userId='" + userId + '\'' +
                '}';
    }
} 